<%@ page language="java" import="java.util.*,com.imaker.domain.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
List<Department> list = (List<Department>)request.getAttribute("departmentList");
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title></title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<link rel="stylesheet" href="<%=path%>/css/plugin/zTree/zTreeStyle.css" type="text/css">
	<link rel="stylesheet" type="text/css" href="js/plugin/frame/css/common.css">
	<link rel="stylesheet" type="text/css" href="js/plugin/frame/css/treePanel.css">
	<script type="text/javascript" src="js/jquery.js"></script>
	<script type="text/javascript" src="js/plugin/frame/treePanel.js"></script>
	<script type="text/javascript" src="js/plugin/zTree/ztree.js"></script>
	<script type="text/javascript">
		var nodes =[
			<% if(list.size()==0){%>
			{'id':'00000000000000000000000000000000', 'pId':'0', 'name':'部门'}
			<%}else {%>
			{'id':'00000000000000000000000000000000', 'pId':'0', 'name':'部门'},
			<%}%>
			<% for(int i=0;i<list.size();i++) {
				Department d = list.get(i);
				if(i!=list.size()-1){
			%>
    		{'id':'<%=d.getId() %>', 'pId':'<%=d.getPid()==null?"00000000000000000000000000000000":d.getPid() %>', 'name':'<%=d.getName() %>'},
    		<%
    		}else {
    		%>
    		{'id':'<%=d.getId() %>', 'pId':'<%=d.getPid()==null?"00000000000000000000000000000000":d.getPid() %>', 'name':'<%=d.getName() %>'}
    		<% }}%>
		];
		$(document).ready(function(){
			new TreePanel({
				renderTo : 'tree',
				treeNodeKey:'id',
				treeNodeParentKey:'pId',
				treeNodes:nodes,
				expandNode:'00000000000000000000000000000000',//要展开 的节点ID
				click:function(event,id,node){
					var id = node.id;
					var src = '<%=path %>/system/user/list.action?department.id='+node.id;
					$("#mainFrame",window.parent.document).attr("src",src);
				},
				load:function(tree){
				var nodes = tree.getNodes();
				var src = '<%=path %>/system/user/list.action?department.id='+nodes[0].id;
				$("#mainFrame",window.parent.document).attr("src",src);
				},
				back:function(){
				var src = '<%=basePath%>/system/workspace/tree.action';
				$("#leftFrame",window.parent.document).attr("src",src);
				}
			});
		});
	</script>
  </head>
  <body>
	<div class="treePanel">
  				<div class="head">
  					<div class="title">系统管理</div>
  					<div class="bar"></div>
  				</div>
  				<div class="panelbody">
					<div class="system"><div class="system_pic"></div><span class="title">部门列表</span><span class="back" title="返回上级"></span></div>
					<div class="treeContent">
						<ul class="tree" id="tree">
							
						</ul>
					</div>
				<div class=start><div class="system_start"></div><span class="title">系统信息</span><span class="back" title="返回上级"></span></div>
  				</div>
  			</div>
  		</div>
  </body>
</html>
